const log4js = require('log4js');

module.exports = (name, options) => {
    name = name || 'default';
    options = Object.assign({level: 'auto'}, options);
    fn = log4js.connectLogger(log4js.getLogger(name), options);
    return async(ctx, next) => {
        await fn(ctx.req, ctx.res, next);
    }
};